<?php
require_once '../include.php';
checkLogined();
$rows=getAllCate();
if(!$rows){
    alertMes("没有相应分类，请先添加分类!!", "addCate.php");
}
$id = $_REQUEST['id'];
$proInfo = getProById($id);

?>
<!doctype html>
<html>
<head>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>大大电子商务后台管理系统</title>

        <!-- BOOTSTRAP STYLES-->
        <link href="styles/css/bootstrap.css" rel="stylesheet" />
        <!-- FONTAWESOME STYLES-->
        <link href="styles/css/font-awesome.css" rel="stylesheet" />
        <!--CUSTOM BASIC STYLES-->
        <link href="styles/css/basic.css" rel="stylesheet" />
        <!--CUSTOM MAIN STYLES-->
        <link href="styles/css/custom.css" rel="stylesheet" />
        <!-- GOOGLE FONTS-->
        <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
        <!-- /. FOOTER  -->
        <link href="./styles/global.css"  rel="stylesheet"  type="text/css" media="all" />
        <script type="text/javascript" charset="utf-8" src="../plugins/kindeditor/kindeditor.js"></script>
        <script type="text/javascript" charset="utf-8" src="../plugins/kindeditor/lang/zh_CN.js"></script>
        <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
        <!-- JQUERY SCRIPTS -->
        <script src="scripts/js/jquery-1.10.2.js"></script>
        <!-- BOOTSTRAP SCRIPTS -->
        <script src="scripts/js/bootstrap.js"></script>
        <!-- METISMENU SCRIPTS -->
        <script src="scripts/js/jquery.metisMenu.js"></script>
        <!-- CUSTOM SCRIPTS -->
        <script src="scripts/js/custom.js"></script>
        <script src="scripts/js/bootstrap-fileupload.js"></script>
        <script type="text/javascript" src="./scripts/jquery-1.6.4.js"></script>
    <script>
        KindEditor.ready(function(K) {
            window.editor = K.create('#editor_id');
        });
        $(document).ready(function(){
            $("#selectFileBtn").click(function(){
                $fileField = $('<input type="file" name="thumbs[]"/>');
                $fileField.hide();
                $("#attachList").append($fileField);
                $fileField.trigger("click");
                $fileField.change(function(){
                    $path = $(this).val();
                    $filename = $path.substring($path.lastIndexOf("\\") + 1);
                    $attachItem = $('<div class="attachItem"><div class="left">a.gif</div><div class="right"><a href="#" title="删除附件">删除</a></div></div>');
                    $attachItem.find(".left").html($filename);
                    $("#attachList").append($attachItem);
                });
            });
            $("#attachList>.attachItem").find('a').live('click',function(obj,i){
                $(this).parents('.attachItem').prev('input').remove();
                $(this).parents('.attachItem').remove();
            });
        });
    </script>
</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.php">大大电子商务</a>
        </div>

        <div class="header-right">
            <a href="doAdminAction.php?act=logout" class="btn btn-danger" title="Logout"><i class="fa fa-sign-out fa-2x"></i></a>
        </div>
    </nav>
    <!-- /. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">
                <li>
                    <div class="user-img-div">
                        <img src="styles/img/user.png" class="img-thumbnail" />

                        <div class="inner-text">
                            欢迎您：<?php
                            if(isset($_SESSION['adminName'])){
                                echo $_SESSION['adminName'];
                            }elseif(isset($_COOKIE['adminName'])){
                                echo $_COOKIE['adminName'];
                            }
                            ?>
                            <br />
                            <td><?php echo "今天是 " . date("Y-m-d")?>日</td>
                        </div>
                    </div>

                </li>


                <li>
                    <a class="active-menu" href="index.html"><i class="fa fa-dashboard "></i>主页</a>
                </li>
                <li>
                    <a href="#"><i class="fa fa-desktop "></i>商品管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="addPro.php"><i class="fa fa-toggle-on"></i>添加商品</a>
                        </li>
                        <li>
                            <a href="listPro.php"><i class="fa fa-bell "></i>商品列表</a>
                        </li>
                        <li>
                            <a href="listProImages.php"><i class="fa fa-bell "></i>商品图片&简介管理</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-yelp "></i>分类管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="addCate.php"><i class="fa fa-coffee"></i>添加分类</a>
                        </li>
                        <li>
                            <a href="listCate.php"><i class="fa fa-flash "></i>分类管理</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-flash "></i>订单管理</a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="listlist.php"><i class="fa fa-desktop "></i>订单查询</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-bicycle "></i>用户管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">

                        <li>
                            <a href="addUser.php"><i class="fa fa-desktop "></i>添加用户</a>
                        </li>
                        <li>
                            <a href="listUser.php"><i class="fa fa-code "></i>用户列表</a>
                        </li>


                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-bicycle "></i>管理员管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">

                        <li>
                            <a href="addAdmin.php"><i class="fa fa-desktop "></i>添加管理员</a>
                        </li>
                        <li>
                            <a href="listAdmin.php"><i class="fa fa-code "></i>管理员列表</a>
                        </li>


                    </ul>
                </li>

                <li>
                    <a href="blank.html"><i class="fa fa-square-o "></i>Blank Page</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-head-line">管理员告示栏</h1>
                    <h1 class="page-subhead-line">这是一些通知事项 </h1>

                </div>
            </div>
            <div class="col-md-8 col-sm-8 col-xs-12">
                <div class="panel panel-info">
                    <div class="panel-heading">
                        修改商品
                    </div>
                    <div class="panel-body">
                        <form role="form" action="doAdminAction.php?act=editPro&id=<?php echo $id;?>" method="post" enctype="multipart/form-data"">
                            <div class="form-group">
                                <label>商品名称</label>
                                <input type="text" name="pName"  value="<?php echo $proInfo['pName'];?>"/>
                                <p class="help-block">请输入商品名称</p>
                            </div>
                            <div class="form-group">
                                <label>商品分类</label>
                                <select name="cId">
                                    <?php foreach($rows as $row):?>
                                        <option value="<?php echo $row['id'];?>"<?php echo $row['id'] == $proInfo['cId']?"selected='selected'":null;?>><?php echo $row['cName'];?></option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>商品货号</label>
                                <input type="text" name="pSn"  value="<?php echo $proInfo['pSn'];?>"/>
                                <p class="help-block">请输入商品货号</p>
                            </div>
                            <div class="form-group">
                                <label>商品数量</label>
                                <input type="text" name="pNum"  value="<?php echo $proInfo['pNum'];?>"/>
                                <p class="help-block">请输入商品数量</p>
                            </div>
                            <div class="form-group">
                                <label>商品官方价</label>
                                <input type="text" name="mPrice"  value="<?php echo $proInfo['mPrice'];?>"/>
                                <p class="help-block">请输入商品市场价</p>
                            </div>
                            <div class="form-group">
                                <label>商品大大价</label>
                                <input type="text" name="iPrice"  value="<?php echo $proInfo['iPrice'];?>"/>
                                <p class="help-block">请输入商品大大价</p>
                            </div>
                            <div class="form-group">
                                <label>商品描述</label>
                                <input class="form-control" type="text" name="pDesc" >
                                <p class="help-block">请输入商品描述</p>
                            </div>
                            <div class="form-group">
                                <td align="right"></td>
                                <td>
                                    <a href="javascript:void(0)" id="selectFileBtn">添加附件</a>
                                    <div id="attachList" class="clear"></div>
                                </td>
                            </div>
                            <!--                            <div class="form-group">-->
                            <!--                                <label class="control-label col-lg-4">上传商品图片</label>-->
                            <!--                                <div class="">-->
                            <!--                                    <div class="fileupload fileupload-new" data-provides="fileupload">-->
                            <!--                                <span class="btn btn-file btn-default">-->
                            <!--                                    <span class="fileupload-new" href="javascript:void(0)" id="selectFileBtn" >选择文件</span>-->
                            <!--                                    <span class="fileupload-exists"></span>-->
                            <!--                                    <input type="file">-->
                            <!--                                </span>-->
                            <!--                                        <span class="fileupload-preview" id="attachList" class="clear"></span>-->
                            <!--                                        <a  class="close fileupload-exists"   style="float: none">×</a>-->
                            <!--                                    </div>-->
                            <!--                                </div>-->
                            <!--                            </div>-->
                            <button type="submit" class="btn btn-info">确认</button>

                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!-- /. PAGE INNER  -->
    </div>
</div>
<div id="footer-sec">
    &copy; 2017 白尚林 | More Templates
</div>
</body>
</html>